
//
//  BaseViewController.m
//  
//
//  Created by MT on 2017/7/29.
//  Copyright © 2017年 MT. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()
@property (nonatomic, strong) MBProgressHUD *hudText;//加载菊花
@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeBottom;
    // Do any additional setup after loading the view.
}
#pragma mark - private methods
/**加载菊花**/
- (void)showMBProgressHUD
{
    _hudText = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
/**加载文字**/
- (void)showMBProgressHUDTextWithMessage:(NSString *)message
{
    _hudText = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
    // Set the text mode to show only text.
    _hudText.mode = MBProgressHUDModeText;
    _hudText.label.text = message;
    // Move to bottm center.
    _hudText.offset = CGPointMake(0.f, MBProgressMaxOffset);
    [self hideMBProgressHUD];
}
/**加载菊花,文字**/
- (void)showMBProgressHUDWithMessage:(NSString *)message
{
    [self showMBProgressHUD];
    _hudText.label.text = message;
}
/**加载成功**/
- (void)showMBProgressHUDWithSuccess:(NSString *)message
{
    [self showMBProgressHUD];
    _hudText.mode = MBProgressHUDModeCustomView;
    _hudText.label.text = message;
    UIImage *normalImage = [UIImage imageNamed:@"HUD_right"];
    _hudText.customView = [[UIImageView alloc] initWithImage:normalImage];
    [self hideMBProgressHUD];
}
/**加载失败**/
- (void)showMBProgressHUDWithFail:(NSString *)message
{
    [self showMBProgressHUD];
    _hudText.mode = MBProgressHUDModeCustomView;
    _hudText.label.text = message;
    UIImage *normalImage = [UIImage imageNamed:@"HUD_error"];
    _hudText.customView = [[UIImageView alloc] initWithImage:normalImage];
    [self hideMBProgressHUD];
}
/**加载警告**/
- (void)showMBProgressHUDWithWarning:(NSString *)message
{
    [self showMBProgressHUD];
    _hudText.mode = MBProgressHUDModeCustomView;
    _hudText.label.text = message;
    UIImage *normalImage = [UIImage imageNamed:@"HUD_tip"];
    _hudText.customView = [[UIImageView alloc] initWithImage:normalImage];
    [self hideMBProgressHUD];
}
/**隐藏菊花**/
- (void)hideMBProgressHUD
{
    dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
        // Do something useful in the background
        [self doSomeWork];
        // IMPORTANT - Dispatch back to the main thread. Always access UI
        // classes (including MBProgressHUD) on the main thread.
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.hudText hideAnimated:YES];
        });
    });
}
- (void)doSomeWork {
    // Simulate by just waiting.
    sleep(3.);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 默认初始化方法
- (void)initConfigure {
    
}
// 默认构建UI方法
- (void)buildInterface {
    
}

@end
